﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace InternRegistration.Model
{
    public class InternManager
    {

        #region Intern Checks
        #region IDControl
        public bool CheckId(Intern intern)
        {

            if (intern.Id >= 10000000000 && intern.Id <= 99999999999)
                return true;
            else
                return false;
        } // end CheckId
        #endregion

        #region NameControl
        public bool CheckName(Intern intern)
        {
            if (intern.Name != null)
                return true;
            else
                return false;
        } // end checkname
        #endregion

        #region SurnameControl
        public bool CheckSurname(Intern intern)
        {
            if (intern.Surname != null)
                return true;
            else
                return false;
        } // end check surname
        #endregion

        #region BirthDateControl

        public bool CheckBirthOfDate(Intern intern)
        {
            if (intern.BirthOfDay != null)
                return true;
            else
                return false;
        } // end check birthday
        #endregion

        #region AddressControl

        public bool CheckAddress(Intern intern)
        {
            if (intern.Address != null)
                return true;
            else
                return false;
        } // end check address
        #endregion

        #region NumberControl
        public bool CheckTelephoneNumber(Intern intern)
        {
            if (intern.TelephoneNumber == null)
                return false;
            else if (intern.TelephoneNumber.Length == 10)
                return true;
            else
                return false;

        } // end checktelephonenumber
        #endregion

        #region EmailControl
        public bool CheckEmail(Intern intern)
        {

            try
            {
                var internMailAddress = new System.Net.Mail.MailAddress(intern.Email);
                return internMailAddress.Address == intern.Email;
            }

            catch
            {
                return false;
            }
        } // end CheckEmail

        #endregion

        #region SchoolControl

        public bool CheckSchool(Intern intern)
        {
            if (intern.School != null)
                return true;
            else
                return false;
        } // end check school
        #endregion

        #region DepartmentControl

        public bool CheckDepartment(Intern intern)
        {
            if (intern.Department != null)
                return true;
            else
                return false;
        } // end departmentcheck
        #endregion

        #region GradeControl
        public bool CheckGrade(Intern intern)
        {
            if (intern.Grade != null)
                return true;
            else
                return false;
        } // end grade check
        #endregion

        #region GPAControl
        public bool CheckGPA(Intern intern)
        {
            //  string Gpa = System.Convert.ToString(intern.GradePointAverage );
            if (0.0 < intern.GradePointAverage && intern.GradePointAverage <= 4.0)
                return true;

            else
                return false;
        } // end gpacheck
        #endregion

        #region SupervisorControl

        public bool CheckSupervisor(Intern intern)
        {
            if (intern.Supervisor != null)
                return true;
            else
                return false;
        } // end supervisor check
        #endregion

        #region LanguagesControl

        public bool CheckProgrammingLanguages(Intern intern)
        {
            if (intern.ProgrammingLanguages != null)
                return true;
            else
                return false;
        } //end check languages
        #endregion

        #region CheckPeriod
        public bool CheckPeriod(Intern intern)
        {

            DateTime date1 = new DateTime();
            DateTime date2 = new DateTime();
            date1 = intern.InternshipStarting;
            date2 = intern.InternshipEnding;
            int result = DateTime.Compare(date1, date2);

            if (result < 0)
                return true;

            else
                return false;

        } // end check period

        #endregion


        #region CheckRegistration
        public bool CheckAdd(Intern intern)
        {
            if (CheckId(intern) && CheckName(intern) && CheckSurname(intern)
                && CheckBirthOfDate(intern) && CheckPeriod(intern) && CheckAddress(intern) && CheckTelephoneNumber(intern)
                 && CheckEmail(intern) && CheckSchool(intern) && CheckDepartment(intern)
                  && CheckGrade(intern) && CheckSupervisor(intern)
                    && CheckGPA(intern) && CheckProgrammingLanguages(intern))
                return true;

            else
                return false;

        } //

        #endregion

       

        #endregion
        



    }
}